<!--
 * @Author: wwssaabb
 * @Date: 2021-06-23 11:21:56
 * @LastEditTime: 2021-06-23 16:15:46
 * @FilePath: \sass_demo\Radio Tab\index.html
-->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Check Box</title>
  <link href="https://fonts.font.im/css?family=MedievalSharp" rel="stylesheet">
  <link rel="stylesheet" href="./css/style.css">
</head>
<body>
  <div class="container">
    <div class="radio_tab">
      <input type="radio" value="1" name='tab1' id="tab-1" checked>
      <label for="taab-1" class="radio_tab_1">
        <p>Tab 1</p>
      </label>

      <input type="radio" value="2" name='tab2' id="tab-2">
      <label for="taab-2" class="radio_tab_2">
        <p>Tab 1</p>
      </label>

      <input type="radio" value="3" name='tab3' id="tab-3">
      <label for="taab-3" class="radio_tab_3">
        <p>Tab 1</p>
      </label>

      <div class="radio_tab_choose"></div>
    </div>
  </div>

  <script>
    let labels=document.querySelectorAll('label')
    labels.forEach((l,index)=>l.onclick=e=>{
      document.querySelectorAll('input').forEach(i=>i.checked=false)
      document.querySelector('#tab-'+(index+1)).checked=true
    })
    document.querySelector('#tab-1').addEventListener('checked',e=>console.log(e))


  </script>
</body>
</html>